package com.lc.pianostudent.conn;

import com.lc.pianostudent.bean.AnswerResultBean;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;

/**
 * Created by Administrator on 2018/2/22.
 */
@HttpInlet(Conn.CONSTELLATION_INDEX)
public class PostConstellationIndex extends BaseAsyPost {

    public String user_id;
    public PostConstellationIndex(AsyCallBack asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected PostConstellationIndexInfo parser(JSONObject object) throws Exception {
        if (object.optString("code").equals("200")) {

            PostConstellationIndexInfo info = new PostConstellationIndexInfo();

            info.code = object.optString("code");
            JSONObject jsonObject = object.optJSONObject("list");

            info.xx = jsonObject.optString("xx");
            info.pintunum = jsonObject.optString("pintunum");
            info.width = jsonObject.optString("width");
            info.num = jsonObject.optString("num");
            info.huangguan = jsonObject.optString("huangguan");
            info.pintuid = jsonObject.optString("pintuid");
            info.height = jsonObject.optString("height");
            info.number = jsonObject.optString("number");
            info.title = jsonObject.optString("title");
            info.content = jsonObject.optString("content");
            JSONArray picarr = jsonObject.optJSONArray("picarr");

            if(picarr != null || picarr.length() != 0){
                for(int i = 0;i<picarr.length();i++){
                    info.imageList.add(picarr.optString(i));
                }
            }
            TOAST = object.optString("message");
            return info;

        } else {

            TOAST = object.optString("message");

        }

        return null;
    }

    public static class PostConstellationIndexInfo {

        public String code,xx,pintunum,num,huangguan,pintuid,width,height,number,title,content;

        public ArrayList<String> imageList = new ArrayList<>();

    }

}
